<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改页面</title>
    <link rel="stylesheet" href="../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <input type="hidden" id="id" name="id" th:value="${product.id}">
            <div class="layui-form-item">
                <label class="layui-form-label">产品绑定测评Id</label>
                <div class="layui-input-block">
                    <input type="text" name="evaId" th:value="${product.evaId}" lay-verify="title" autocomplete="off"
                           placeholder="请输入标题"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">产品名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" th:value="${product.title}" lay-verify="title" autocomplete="off"
                           placeholder="请输入标题"
                           class="layui-input">
                </div>
            </div>
            <!--					<div class="layui-form-item">-->
            <!--						<label class="layui-form-label">姓名</label>-->
            <!--						<div class="layui-input-block">-->
            <!--							<input type="text" name="realName" lay-verify="title" autocomplete="off" placeholder="请输入标题"-->
            <!--								class="layui-input">-->
            <!--						</div>-->
            <!--					</div>-->
            <!--					<div class="layui-form-item">-->
            <!--						<label class="layui-form-label">邮箱</label>-->
            <!--						<div class="layui-input-block">-->
            <!--							<input type="text" name="email" lay-verify="title" autocomplete="off" placeholder="请输入标题"-->
            <!--								class="layui-input">-->
            <!--						</div>-->
            <!--					</div>-->
            <div class="layui-form-item">
                <label class="layui-form-label">价格</label>
                <div class="layui-input-block">
                    <!--/*@thymesVar id="price" type="tech.maiquer.metrichall.wxpay.entity.Product"*/-->
                    <input type="text" name="price" th:value="${product.price}" lay-verify="title" autocomplete="off" placeholder="请输入标题"
                           class="layui-input">
                </div>
            </div>
            <!--					<div class="layui-form-item">-->
            <!--						<label class="layui-form-label">电话</label>-->
            <!--						<div class="layui-input-block">-->
            <!--							<input type="text" name="phone" lay-verify="title" autocomplete="off" placeholder="请输入标题"-->
            <!--								class="layui-input">-->
            <!--						</div>-->
            <!--					</div>-->
<!--            <div class="layui-form-item">-->
<!--                <label class="layui-form-label">角色</label>-->
<!--                <div class="layui-input-block">-->
<!--                    <input type="radio" name="roleId" value=2 title="普通用户">-->
<!--                    <input type="radio" name="roleId" value=1 title="超级管理员" checked>-->
<!--                </div>-->
<!--            </div>-->
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="product-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(product-save)', function (data) {
            console.log(data)
            $.ajax({
                url: '/api/product/editProduct',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code === 0) {
                        layer.msg(result.message, {
                            icon: 1,
                            time: 1000
                        }, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window
                                .name)); //关闭当前页
                            parent.layui.table.reload("product-table");
                        });
                    } else {
                        layer.msg(result.message, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });
    })
</script>
<script>
</script>
</body>
</html>
